"use strict";
cc._RF.push(module, '8973fe1GcROzbCQ8UqCsRuZ', 'CarWeaponControl');
// scripts/CarWeaponControl.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("GameConstant"),
    s = t("GameLogic"),
    l = t("Util"),
    c = t("CarConstant"),
    d = t("CarWheelWeaponControl"),
    h = t("GatlinBullet"),
    p = t("Grenade"),
    u = t("RocketItem"),
    f = t("ShotGunBullet"),
    m = t("WeaponControl"),
    _ = cc._decorator,
    y = _.ccclass,
    g = _.property,
    v = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.node_wheel0 = null, e.node_wheel1 = null, e._gameLogic = new s.GameLogic(), e._gameControl = null, e.isGameOver = !0, e.nCarTag = 0, e.bSawCollision = !1, e.bElecSawCollision = !1, e._wheel0Control = null, e._wheel1Control = null, e.curSawDate = 0, e.curElecSawDate = 0, e.curSceneRightSawDate = 0, e.curSceneLeftSawDate = 0, e.bCanAttack = !0, e.bSceneRightSaw = !1, e.bSceneLeftSaw = !1, e.isHammerDamage = !1, e.isdoubleSawDamage = !1, e.isSawDamage = !1, e.nElecSawAudioID = 0, e.isElecSawDamage = !1, e;
  }

  return n(e, t), e.prototype.onLoad = function () {
    this._wheel0Control = this.node_wheel0.getComponent(d["default"]), this._wheel1Control = this.node_wheel1.getComponent(d["default"]);
  }, e.prototype.update = function (t) {
    this.isGameOver || (this.damageLefSawHp(!0, t), this.damageRightSawHp(!0, t), this.damageSawHp(!0, t), this.damageElecSawHp(!0, t));
  }, e.prototype.init = function (t, e, o) {
    this._gameControl = t, this.nCarTag = e, this.isGameOver = !0, this.node.getComponent(cc.Collider).tag = this._gameLogic.getCollideTag(e, r.Collide_Weapon_Tag.Car), this._wheel0Control.init(this, e, o[0]), this._wheel1Control.init(this, e, o[1]);
  }, e.prototype.onGameStart = function () {
    this.isGameOver = !1, this._wheel0Control.onGameStart(), this._wheel1Control.onGameStart();
  }, e.prototype.onGameOver = function () {
    this.isGameOver = !0, this._wheel0Control.onGameOver(), this._wheel1Control.onGameOver();
  }, e.prototype.onGameBoutReady = function () {
    this._wheel0Control.onGameBoutReady(), this._wheel1Control.onGameBoutReady();
  }, e.prototype.onGameBoutStart = function () {
    this.bCanAttack = !0, this.isGameOver = !1, this._wheel0Control.onGameBoutStart(), this._wheel1Control.onGameBoutStart();
  }, e.prototype.onGameBoutOver = function () {
    this.isGameOver = !0, this._wheel0Control.onGameBoutOver(), this._wheel1Control.onGameBoutOver();
  }, e.prototype.onCanAttack = function (t) {
    this.bCanAttack = t;
  }, e.prototype.onAirShipIn = function () {
    this.node.active = !1, this._wheel0Control.onAirShipIn(), this._wheel1Control.onAirShipIn();
  }, e.prototype.onAirShipOut = function () {
    this.node.active = !0, this._wheel0Control.onAirShipOut(), this._wheel1Control.onAirShipOut();
  }, e.prototype.onCollisionEnter = function (t, e) {
    if (!this.isGameOver) {
      var o = this._gameLogic.getColliderCarTag(e.tag);

      if (t.node.group === r.Collide_Group_Blade) {
        if (o == this.nCarTag) return void (t.tag == r.Collide_Weapon_Tag.SceneRight_Saw ? (this.damageRightSawHp(!1), this.bSceneRightSaw = !0) : t.tag == r.Collide_Weapon_Tag.SceneLeft_Saw && (this.damageLefSawHp(!1), this.bSceneLeftSaw = !0));
      } else t.node.group == r.Collide_Group_Car.body ? o == this.nCarTag && this.onCollideCarBody("bodyBody", !0, !1) : t.node.group == r.Collide_Group_Car.wheel && o == this.nCarTag && this.onCollideCarBody("bodyWheel", !0, !1);

      var i = this._gameLogic.getColliderCarTag(t.tag),
          n = t.world.position;

      if (i != o && o == this.nCarTag) switch (this._gameLogic.getColliderWeaponTag(t.tag)) {
        case r.Collide_Weapon_Tag.Hammer:
          this.damageHammerHp(n), l.Util.respownStarParticle(n), this.isHammerDamage = !0;
          break;

        case r.Collide_Weapon_Tag.Saw:
          this.isSawDamage = !0, this.bSawCollision = !0, this.damageSawHp(!1);
          break;

        case r.Collide_Weapon_Tag.Rocket:
          this.damageRocketHp(t);
          break;

        case r.Collide_Weapon_Tag.ElecSaw:
          this.damageElecSawHp(!1), this.isElecSawDamage = !0;
          break;

        case r.Collide_Weapon_Tag.Fist:
          this.damageFistHp(), l.Util.respownStarParticle(n);
          break;

        case r.Collide_Weapon_Tag.Harpoon:
          this.damageHarpoon(t);
          break;

        case r.Collide_Weapon_Tag.DoubleSaw:
          this.damageDoubleSawHp(n), l.Util.respownStarParticle(n), this.isdoubleSawDamage = !0;
          break;

        case r.Collide_Weapon_Tag.Gatlin:
          this.damageGatlinHp(t);
          break;

        case r.Collide_Weapon_Tag.Grenade:
          this.damageGrenadeHp(t);
          break;

        case r.Collide_Weapon_Tag.Laser:
          this.damageLaserHp(t);
          break;

        case r.Collide_Weapon_Tag.shotgun:
          this.damageShotgunHp(t);
          break;

        case r.Collide_Weapon_Tag.boomerang:
          this.damageBoomerangHp(t);
      }
    }
  }, e.prototype.onCollisionStay = function () {
    this.isGameOver;
  }, e.prototype.onCollisionExit = function (t, e) {
    if (!this.isGameOver) {
      var o = this._gameLogic.getColliderCarTag(e.tag);

      if (t.node.group === r.Collide_Group_Blade) {
        if (o == this.nCarTag) return o == this.nCarTag ? void (t.tag == r.Collide_Weapon_Tag.SceneRight_Saw ? this.bSceneRightSaw = !1 : t.tag == r.Collide_Weapon_Tag.SceneLeft_Saw && (this.bSceneLeftSaw = !1)) : void 0;
      } else t.node.group == r.Collide_Group_Car.body ? o == this.nCarTag && this.onCollideCarBody("bodyBody", !1, !0) : t.node.group == r.Collide_Group_Car.wheel && o == this.nCarTag && this.onCollideCarBody("bodyWheel", !1, !0);

      var i = this._gameLogic.getColliderCarTag(t.tag);

      if (i != o && o == this.nCarTag) switch (this._gameLogic.getColliderWeaponTag(t.tag)) {
        case r.Collide_Weapon_Tag.Hammer:
          this.isHammerDamage = !1;
          break;

        case r.Collide_Weapon_Tag.Saw:
          this.isSawDamage = !1, this.bSawCollision = !1, this.sawLeaveCar(i, r.Collide_Weapon_Tag.Saw);
          break;

        case r.Collide_Weapon_Tag.Rocket:
          break;

        case r.Collide_Weapon_Tag.ElecSaw:
          this.isElecSawDamage = !1, this.bElecSawCollision = !1, this.curElecSawDate = 0, this.eleSawLeaveCar();
          break;

        case r.Collide_Weapon_Tag.Fist:
          break;

        case r.Collide_Weapon_Tag.DoubleSaw:
          this.isdoubleSawDamage = !1;
      }
    }
  }, e.prototype.damageRightSawHp = function (t, e) {
    this.bSceneRightSaw || this._wheel0Control.bSceneRightSaw || this._wheel1Control.bSceneRightSaw ? (e || (e = 0), this.curSceneRightSawDate += e, this.curSceneRightSawDate >= r.SceneSaw_Time_interval && (this.damageSceneSawHp(r.Collide_Weapon_Tag.SceneRight_Saw), this.curSceneRightSawDate -= r.SceneSaw_Time_interval)) : t ? this._gameControl.weaponLeaveCar(this.nCarTag, r.Collide_Weapon_Tag.SceneRight_Saw) : (this.curSceneRightSawDate = 0, this.damageSceneSawHp(r.Collide_Weapon_Tag.SceneRight_Saw));
  }, e.prototype.damageLefSawHp = function (t, e) {
    this.bSceneLeftSaw || this._wheel0Control.bSceneLeftSaw || this._wheel1Control.bSceneLeftSaw ? (e || (e = 0), this.curSceneLeftSawDate += e, this.curSceneLeftSawDate >= r.SceneSaw_Time_interval && (this.damageSceneSawHp(r.Collide_Weapon_Tag.SceneLeft_Saw), this.curSceneLeftSawDate -= r.SceneSaw_Time_interval)) : t ? this._gameControl.weaponLeaveCar(this.nCarTag, r.Collide_Weapon_Tag.SceneLeft_Saw) : (this.curSceneLeftSawDate = 0, this.damageSceneSawHp(r.Collide_Weapon_Tag.SceneLeft_Saw));
  }, e.prototype.damageSceneSawHp = function (t) {
    this._gameControl.damageHp(this.nCarTag, t, !0);
  }, e.prototype.damageHammerHp = function (t) {
    this.bCanAttack && (this.isHammerDamage || this._wheel0Control.isHammerDamage || this._wheel1Control.isHammerDamage || (this._gameControl.playSound(this._gameControl._audioControl.body_hit1), this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.Hammer), this._gameControl.playHammerEffect(this.nCarTag, t, c.Weapon_ID.Hammer)));
  }, e.prototype.mineBlowOff = function (t) {
    this._gameControl.playSound(this._gameControl._audioControl.rocket_hit), this._gameControl.mineBlowOff(this.nCarTag, t);
  }, e.prototype.damageDoubleSawHp = function (t) {
    console.log("产生伤害"), this.bCanAttack && (this.isdoubleSawDamage || this._wheel0Control.isdoubleSawDamage || this._wheel1Control.isdoubleSawDamage || (this._gameControl.playSound(this._gameControl._audioControl.body_hit1), this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.DoubleSaw), this._gameControl.playHammerEffect(this.nCarTag, t, c.Weapon_ID.DoubleSaw)));
  }, e.prototype.damageSawHp = function (t, e) {
    if (this.bCanAttack) if (this.bSawCollision || this._wheel0Control.bSawCollision || this._wheel1Control.bSawCollision) e || (e = 0), this.curSawDate += e, this.curSawDate >= l.Util.attackSpeed(r.Saw_Time_interval, this.nCarTag) && (this._gameControl.playSound(this._gameControl._audioControl.spin_loop), this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.Saw), this.curSawDate -= l.Util.attackSpeed(r.Saw_Time_interval, this.nCarTag));else if (!t) return void this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.Saw);
  }, e.prototype.damageElecSawHp = function (t, e) {
    this.bCanAttack && (this.isElecSawDamage || this._wheel0Control.isElecSawDamage || this._wheel1Control.isElecSawDamage ? (e || (e = 0), this.curElecSawDate += e, this.curElecSawDate >= l.Util.attackSpeed(r.ElecSaw_Time_interval, this.nCarTag) && (this.nElecSawAudioID = this._gameControl.playAudio(r.Game_Audio_ID.saw_hit), this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.ElecSaw), this.curElecSawDate -= l.Util.attackSpeed(r.ElecSaw_Time_interval, this.nCarTag))) : t || (this.curElecSawDate = 0, this.nElecSawAudioID = this._gameControl.playAudio(r.Game_Audio_ID.saw_hit), this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.ElecSaw)));
  }, e.prototype.eleSawLeaveCar = function () {
    0 != this.nElecSawAudioID && this._gameControl.stopAudio(this.nElecSawAudioID);
  }, e.prototype.sawLeaveCar = function (t, e) {
    this.isSawDamage || this._wheel0Control.isSawDamage || this._wheel1Control.isSawDamage || this._gameControl.weaponLeaveCar(t, e);
  }, e.prototype.damageRocketHp = function (t) {
    this._gameControl.playSound(this._gameControl._audioControl.rocket_hit), t.node.parent.getComponent(u["default"]).removeItem(), this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.Rocket, !1, t);
  }, e.prototype.damageGatlinHp = function (t) {
    this._gameControl.playSound(this._gameControl._audioControl.gatlin_hit, .3);

    var e = t.world.position;
    t.node.parent.parent.getComponent(h["default"]).removeItem(e), this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.Gatlin, !1, t);
  }, e.prototype.damageGrenadeHp = function (t) {
    var e = t.world.position;
    this._gameControl.playSound(this._gameControl._audioControl.rocket_hit), t.node.parent.getComponent(p["default"]).removeItem(e), this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.Grenade, !1, t);
  }, e.prototype.damageLaserHp = function (t) {
    console.log("damageLaserHp"), this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.Laser, !1, t);
  }, e.prototype.damageShotgunHp = function (t) {
    t.node.parent.getComponent(f["default"]).removeItem(), this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.shotgun, !1, t), this._gameControl.playHammerEffect(this.nCarTag, t.world.position, c.Weapon_ID.shotgun);
  }, e.prototype.damageBoomerangHp = function (t) {
    this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.boomerang, !1, t);
  }, e.prototype.damageFistHp = function () {
    this.bCanAttack && this._gameControl.damageHp(this.nCarTag, r.Collide_Weapon_Tag.Fist);
  }, e.prototype.damageHarpoon = function (t) {
    var e = t.world.position;

    this._gameControl.onPlayHarpoon(this.nCarTag, e);
  }, e.prototype.onCollideCarBody = function (t, e, o) {
    this._gameControl.onCollideCarBody(t, e, o);
  }, e.prototype.onCollideCarWheel = function (t, e, o) {
    this._gameControl && this._gameControl.onCollideCarWheel(t, e, o);
  }, a([g(cc.Node)], e.prototype, "node_wheel0", void 0), a([g(cc.Node)], e.prototype, "node_wheel1", void 0), a([y], e);
}(m["default"]);

o["default"] = v;

cc._RF.pop();